package com.example.contrpller;

import com.example.entiy.SMSCode;
import com.example.service.SMSService;
import com.example.uilt.CodeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sms")
public class SMSCodeController {
    @Autowired
    private SMSService smsService;

    @Autowired
    private CodeUtil codeUtil;
    @RequestMapping("/send")
    public String send(String tele){
        String code = smsService.sendCode(tele);
        return code;
    }

    @RequestMapping("/check")
    public boolean check(SMSCode smsCode) {
        String code=smsCode.getCode();
        String caheCode=codeUtil.get(smsCode.getTele());
        return code.equals(caheCode);
    }
}
